/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Echo;

import java.io.*;
import java.net.*;

public class EchoClient {

    public static void main(String[] args) throws IOException {

        Socket kkSocket = null;
        PrintWriter out = null;
        BufferedReader in = null;

        try {
            kkSocket = new Socket("mez-noskov", 4444);
            out = new PrintWriter(kkSocket.getOutputStream(), true);
            //in = new BufferedReader(new InputStreamReader(kkSocket.getInputStream()));
            in = new BufferedReader(new InputStreamReader(System.in));
        } catch (UnknownHostException e) {
            System.err.println("Don't know about host: taranis.");
            System.exit(1);
        } catch (IOException e) {
            System.err.println("Couldn't get I/O for the connection to: taranis.");
            System.exit(1);
        }

        BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
        String fromConsole;
        String fromUser;

        while ((fromConsole = in.readLine()) != null) {
            System.out.println(fromConsole);
            out.println(fromConsole);
            
            if (fromConsole.equals("quit")) {
                break;
            }

//            fromUser = stdIn.readLine();
//            if (fromUser != null) {
//                System.out.println("Client: " + fromUser);
//                out.println(fromUser);
//            }
        }

        out.close();
        in.close();
        stdIn.close();
        kkSocket.close();

    }
}
